<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=1180,initial-scale=0,user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="format-detection" content="telephone=no"/>
    <meta name="renderer" content="webkit">
    <title>账户登录</title>
    <link rel="shortcut icon" href="/static/papper/images/log2.png">
    <link type="text/css" href="/static/papper/style/reset.css" rel="stylesheet">
    <link type="text/css" href="/static/papper/style/register.css?v=190312" rel="stylesheet">
    <script src="/static/hplus/js/jquery.min.js" type="text/javascript"></script>
    <script src="/static/papper/js/NTClientJavascript.js" type="text/javascript"></script>
</head>
<body style="background: url('https://unkown-play.oss-cn-hangzhou.aliyuncs.com/gt-toolbox/d57cd802-e2e8-48dc-9d92-b516c1dcd984.jpg') no-repeat;
        background-size: 100% 100%;
        background-attachment: fixed;">
<script>
    if (window != top) {
        top.location.href = window.location.href;
    }
</script>
<form name="loginForm" id="login_form" method="post" action="#">
    <h2 class="text-center" th:text="${sysSystem.systemName}">后台管理系统</h2>
    <div></div>
    <div class="div_user">
        <span></span>
        <input class="username" id="loginName" type="text" placeholder="请输入用户名或手机号码">
    </div>
    <div class="div_pw">
        <span></span>
        <input class="pw" id="loginPass" type="password" placeholder="请输入密码">
    </div>
    <div class="div_pw" id="captcha_box" style="">
        <span></span>
        <input class="captcha" id="checkNumber" type="text" placeholder="请输入图片验证码" onKeyUp="keyup();">
        <div style=" position: absolute; right: 4px;  top: 8px; cursor: pointer; border: none; background: none;">
            <img src="/kaptcha" onclick='this.src="/kaptcha?" + Math.random()' width="120" height="35">
        </div>
    </div>
    <div class="div_pw">
        <span></span>
        <input class="pw" id="googleSecret" type="number" placeholder="请输入谷歌验证码">
    </div>
    <div id="loginTips"></div>
    <div style="">
        <input id="loginButton" class="login_btn" type="button" value="登录" onclick="UserLogin();">
    </div>
</form>
<script>
    function keyup() {
        if (event.keyCode == 13) {
            event.returnValue = false;
            event.cancel = true;
            $("#loginButton").click();
        }
    }

    function UserLogin() {
        var j = $('.login_btn');
        var e = $('#loginTips');
        e.html("").hide();
        if (j.val() == '登录中...') return;
        j.val('登录中...');
        var loginName = $('#loginName').val();
        var loginPass = $('#loginPass').val();
        var checkNumber = $('#checkNumber').val();
        var googleSecret = $('#googleSecret').val();
        if (!loginName || !loginPass || !checkNumber) {
            j.val('登录');
            e.html('&nbsp; 缺少必填内容').show();
            return;
        }
        var values = {};
        modifyVerf(values);
        $.ajax({
            url: '/login',
            type: 'post',
            dataType: 'json',
            data: {
                loginName: loginName,
                loginPass: loginPass,
                checkNumber: checkNumber,
                googleSecret: googleSecret,
                cmd5: values.cmd5,
                uid: values.uid,
                randomData: values.randomData
            },
            success: function (rtnObj) {
                if (rtnObj.statusCode == 200) {
                    window.location.href = 'index';
                } else {
                    e.html('&nbsp; ' + rtnObj.message).show();
                    j.val('登录');
                }
            }
        });
    }

    /**
     * 添加KEY信息
     */
    function modifyVerf(values) {
        var rondomData = uuid(16, 16);
        var uid = '';
        var ClientDigest = '';
        var browser = DetectBrowser();
        if (browser != "Unknown") {
            createElementNT199();
            var create = DetectNT199Plugin();
            if (create != false) {
                if (1 <= NT199_Find()) {
                    var retVal = NT199_CheckPassword("12345678");
                    if (retVal == 0) {
                        uid = NT199_GetHardwareId();
                        var randomMessageFromServer = rondomData;
                        ClientDigest = NT199_Sha1WithSeed(randomMessageFromServer);
                    }
                }
            }
        }
        values.cmd5 = ClientDigest;
        values.uid = uid;
        values.randomData = rondomData;
    }

    function uuid(len, radix) {
        var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
        var uuid = [], i;
        radix = radix || chars.length;

        if (len) {
            for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
        } else {
            var r;
            uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
            uuid[14] = '4';

            for (i = 0; i < 36; i++) {
                if (!uuid[i]) {
                    r = 0 | Math.random() * 16;
                    uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
                }
            }
        }
        return uuid.join('');
    }
</script>
</body>
</html>